package com.waterdispenser.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 *
 * @TableName t_machine
 */
@TableName(value ="t_machine")
@Data
@AllArgsConstructor
public class TMachine implements Serializable {
    /**
     * 机器ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id")
    private Long id;

    /**
     * 机器状态，0：关，1：开
     */
    @TableField(value = "state")
    private Integer state;

    /**
     * 本机ip
     */
    @TableField(value = "local_ip")
    private String localIp;

    /**
     * 机器位置
     */
    @TableField(value = "location")
    private String location;

    /**
     * 水源水质
     */
    @TableField(value = "source_water_quality")
    private Integer sourceWaterQuality;

    /**
     * 饮水水质
     */
    @TableField(value = "drinking_water_quality")
    private Integer drinkingWaterQuality;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TMachine other = (TMachine) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
            && (this.getLocalIp() == null ? other.getLocalIp() == null : this.getLocalIp().equals(other.getLocalIp()))
            && (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()))
            && (this.getSourceWaterQuality() == null ? other.getSourceWaterQuality() == null : this.getSourceWaterQuality().equals(other.getSourceWaterQuality()))
            && (this.getDrinkingWaterQuality() == null ? other.getDrinkingWaterQuality() == null : this.getDrinkingWaterQuality().equals(other.getDrinkingWaterQuality()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
        result = prime * result + ((getLocalIp() == null) ? 0 : getLocalIp().hashCode());
        result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
        result = prime * result + ((getSourceWaterQuality() == null) ? 0 : getSourceWaterQuality().hashCode());
        result = prime * result + ((getDrinkingWaterQuality() == null) ? 0 : getDrinkingWaterQuality().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", state=").append(state);
        sb.append(", localIp=").append(localIp);
        sb.append(", location=").append(location);
        sb.append(", sourceWaterQuality=").append(sourceWaterQuality);
        sb.append(", drinkingWaterQuality=").append(drinkingWaterQuality);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
